//
//  NewsViewCell.m
//  LCSJieMianApp
//
//  Created by 千锋 on 15/12/19.
//  Copyright (c) 2015年 1000phone. All rights reserved.
//

#import "NewsViewCell.h"
#import "UIImageView+WebCache.h"

#define IMAGEWIDTH 320
#define IMAGEhEIGHT 160
@implementation NewsViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)layoutSubviews
{
    _NewsImageView.layer.masksToBounds = YES;
    _NewsImageView.layer.cornerRadius = 5;

    CGSize cellSize = self.frame.size;
    if (!_model.publishtime) {
        
        CGRect rect = _NewsImageView.frame;
        _NewsImageView.frame = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, 200);
        [_NewsImageView sd_setImageWithURL:[NSURL URLWithString:_model.img] placeholderImage:[UIImage imageNamed:@"feed_cell_photo_default_big"]];
                if (_titleLabel) {
            _titleLabel.text = @"";
        }if (_timeLabel) {
            _timeLabel.text = @"";
        }if (_authorLabel) {
            _authorLabel.text = @"";
        }if (_commentLabel) {
            _commentLabel.text = @"";
        }if (_seeLabel) {
            _seeLabel.text = @"";
        }if (_commentImage) {
            _commentImage.hidden = YES;
        }if (_seeImage) {
            _seeImage.hidden = YES;
        }
    }else
    {
        _seeImage.hidden = NO;
        _commentImage.hidden = NO;
        _titleLabel.text = _model.title;
        _titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
        _seeLabel.text = @"0";
        _commentLabel.text = @"0";
        UIImage *image = [UIImage imageNamed:@"cell_comment"];
        _commentImage.image = image;
        UIImage *image1 = [UIImage imageNamed:@"cell_pv"];
        _seeImage.image = image1;
        [_NewsImageView sd_setImageWithURL:[NSURL URLWithString:_model.img] placeholderImage:[UIImage imageNamed:@"feed_cell_photo_default_big"]];
        
        if (_model.author_list.count ==  1) {
            NSDictionary *dict = _model.author_list[0];
            _authorLabel.text = dict[@"name"];
            
            _authorLabel.lineBreakMode = NSLineBreakByWordWrapping;
            }
        _timeLabel.text = _model.publishtime;
        _commentLabel.text = _model.comment;
        _seeLabel.text = _model.headline;
    }

}
@end
